<?php

namespace App\Console\Commands;

use App\Repositories\WebSocket\ClientManager;
use SwooleTW\Http\Commands\HttpServerCommand;

class IMCommand extends HttpServerCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'im:swoole {action : start|stop|restart|reload|infos}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Swoole HTTP Server';

    /**
     * Run swoole_http_server.
     */
    protected function start()
    {
        if ($this->isRunning()) {
            $this->error('Failed! swoole_http_server process is already running.');
            return;
        }

        (new ClientManager)->clearRedisCache();

        $this->info("server start!");
        parent::start();
    }
}
